package com.xly.webclick.vm;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.webkit.WebView;

import com.xly.webclick.base.BaseViewModel;
import com.xly.webclick.view.LoginActivity;

/**
 * Created by xuleyuan on 2018/8/18
 */

public class LoginViewModel extends BaseViewModel {

    public LoginViewModel(LoginActivity view) {
        super(view);
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
//        initWebView(((LoginActivity)getActivity()).binding.webView);

    }


    @Override
    public void onResume() {

    }

    @Override
    public void onDestroy() {

    }

    @Override
    public void onStop() {

    }

    @Override
    public void onPause() {

    }

    @Override
    public void onRestart() {

    }

    @SuppressLint("SetJavaScriptEnabled")
    private void initWebView(final WebView paramWebView) {
//        WebSettings localWebSettings = paramWebView.getSettings();
//        localWebSettings.setDefaultTextEncodingName("GBK");
//        localWebSettings.setJavaScriptCanOpenWindowsAutomatically(true);
//        localWebSettings.setJavaScriptEnabled(true);
//        localWebSettings.setDomStorageEnabled(true);
//        localWebSettings.setBuiltInZoomControls(true);
//        localWebSettings.setUseWideViewPort(true);
//        localWebSettings.setLoadWithOverviewMode(true);
//        localWebSettings.setUserAgentString("");
//        paramWebView.setWebViewClient(new WebViewClient() {
//            public void onPageFinished(WebView webView, String paramAnonymousString) {
//                super.onPageFinished(webView, paramAnonymousString);
//                webView.loadUrl("javascript:" + StringUtils.getJson("ip.js", getView()));
//                webView.evaluateJavascript("GetIP_TaoBao()", data -> {
//                    data = data.replace("\\", "");
//                    data = data.substring(1, data.length() - 1);
//                    Message localMessage = Message.obtain();
//                    localMessage.obj = data;
//                    localMessage.what = 5;
////                    LoginActivity.this.handler.sendMessage(localMessage);
//                });
//            }
//        });
//        paramWebView.setWebChromeClient(new WebChromeClient() {
//        });
//        paramWebView.loadUrl("http://ip.taobao.com/ipSearch.html");
    }

}
